<?php

namespace App\Http\Controllers\Api\User;

use App\Http\Controllers\Controller;
use App\Models\User\Repositories\Interfaces\UserRepositoryInterface;
use App\Models\User\User;
use Illuminate\Http\Request;

class UserController extends Controller
{
    private UserRepositoryInterface $userRepo;

    public function __construct(UserRepositoryInterface $repository)
    {
        $this->userRepo = $repository;
    }

    public function phone(Request $request)
    {
        $user = new User();
        $this->userRepo->updateUser($user, [
            'phone' => $request->input('phone'),
        ]);

        return $this->success('success');
    }

    public function broadcast_auth(Request $request)
    {

        if (!auth()->id()) {
            return $this->error(401, '认证失败', [], 401);
        }
        return $this->success('认证成功');
    }
}
